package ar.edu.utn.frba.dds.tp.tests.DateParser;


import static org.junit.Assert.assertEquals;

import org.joda.time.LocalDate;
import org.junit.Before;
import org.junit.Test;

import ar.edu.utn.frba.dds.tp.code.dateParser.CantParseException;
import ar.edu.utn.frba.dds.tp.code.dateParser.FormatoSimple;


public class FormatoSimpleTest {
	
	/*
	 * Tester Mart�n Belocchio
	 */

	FormatoSimple formatoISO, formatoLat, formatoUSA, formatoUSA2;
	
	@Before
	public void setUp() throws Exception {
		formatoISO = new FormatoSimple("yyyy-MM-dd");
		formatoLat = new FormatoSimple("dd/MM/yyyy");
		formatoUSA = new FormatoSimple("MM-dd-yyyy");
	}
	
	@Test
	public void testParseEquals(){
		assertEquals(formatoISO.parse("2012-12-27"),formatoLat.parse("27/12/2012"));
	}
	
	@Test
	public void testParsePrintln(){
		assertEquals("2012-12-27", formatoISO.getFormatter().format(formatoUSA.parse("12-27-2012")));
	}
	
	
	@Test
	public void testParseDateToStringFormatted(){
		assertEquals("2012-12-27", formatoISO.getFormatter().format(new LocalDate(2012,12,27).toDate()));
		
	
	}
	
	@Test (expected=CantParseException.class)
	public void testParseException(){
		formatoLat.parse("27,12,2012");
	}
	
}
